<pre>
<tt>
<font color="#FF0000">/**	\author    coidgen 0.7.4</font>
<font color="#FF0000">	\version    (0.0 build 1)</font>
<font color="#FF0000">	\date      </font>
<font color="#FF0000">	\brief     </font>
<font color="#FF0000">*/</font>



<font color="#FF0000">// Service header info (for version checking),  ! DO NOT CHANGE !</font>
<font color="#0000FF">static</font> <font color="#0000FF">const</font> <font color="#0000FF">char</font> COID_bin_data[] =
<font color="#000000">"060005000000302E372E3409000000312E302028312E3029A10B0000E38BD64000000000000000000000000001000000"</font>
<font color="#000000">"0100000001000000070000006578616D706C65000000000000000000000000050000000500000005000000FFFFFFFF04"</font>
<font color="#000000">"0000006F7063640000000000000000000080000000000500000072656164310000000001000000FFFFFFFF0A00000046"</font>
<font color="#000000">"4F4F5F535452554354000000000000000000000208000000000107200000000000000000FFFFFFFF040000006F706364"</font>
<font color="#000000">"0000000000000000000080000000000500000072656164320100000001000000FFFFFFFF0A000000464F4F5F53545255"</font>
<font color="#000000">"435400000000000000000100080C000000000107200200000000000000FFFFFFFF040000006F70636400000000000000"</font>
<font color="#000000">"00000080000000000400000073656E640200000003000000FFFFFFFF03000000696E7400000000000000000000040800"</font>
<font color="#000000">"0000FFFFFFFF0D000000636F6E73742063686172737472000000000000000000001108000000FFFFFFFF0C0000006269"</font>
<font color="#000000">"6E73747265616D627566000000000000000000000208000000010107200000000000000000FFFFFFFF040000006F7063"</font>
<font color="#000000">"640000000000000000000080000000000900000072656D61705F666E630300000001000000FFFFFFFF0D00000052454D"</font>
<font color="#000000">"41505F4558414D504C45000000000000000000000208000001FFFFFFFF1800000052454D41505F4558414D504C455F63"</font>
<font color="#000000">"6C69656E7473696465000000000000000000000208000000000007200100000000000000FFFFFFFF040000006F706364"</font>
<font color="#000000">"000000000000000000008000000000070000006765745F7074720400000001000000FFFFFFFF0A000000464F4F5F5354"</font>
<font color="#000000">"5255435400000000000000000200010400000000000120000000000000000001FFFFFFFF040000006F70636400000000"</font>
<font color="#000000">"00000000000080000000000E0000006163636570745F636F6E6E6563740500008002000000FFFFFFFF0D000000636F6E"</font>
<font color="#000000">"73742063686172737472000000000000000000001108000000FFFFFFFF0E000000636F6E73742070617373776F726400"</font>
<font color="#000000">"000000000000000000310800000000008720000000000000000001FFFFFFFF040000006F706364000000000000000000"</font>
<font color="#000000">"008000000000150000006163636570745F636F6E6E6563745F7368617265640600008000000000005080200000000000"</font>
<font color="#000000">"00000000000001FFFFFFFF040000006F706364000000000000000000008000000000150000006163636570745F737461"</font>
<font color="#000000">"727475705F706172616D73FFFF008001000000FFFFFFFF0D000000636D645F696E746572666163650000000000000000"</font>
<font color="#000000">"0000010800000000008720000000000000000000000001000700FFFFFFFF00000000"</font>
;
<font color="#FF0000">//*/</font>


<font color="#000080">#include</font> <font color="#000000">"coid/comm/interfnc.h"</font>
<font color="#000080">#include</font> <font color="#000000">"example.h"</font>


<font color="#0000FF">namespace</font> coid <font color="#000080">{</font>


<font color="#0000FF">static</font> <font color="#0000FF">inline</font> <font color="#0000FF">const</font> <font color="#0000FF">char</font> ** <font color="#000000">COID_OUT_ARGS(</font><font color="#0000FF">const</font> <font color="#0000FF">char</font> ** from) <font color="#000080">{</font>
	<font color="#0000FF">while</font>( *from ) from++;
	<font color="#0000FF">return</font> ++from;
<font color="#000080">}</font>

<font color="#0000FF">typedef</font> ServiceDescriptor::MethodDesc MethodDesc;
<font color="#000080">#define</font> <font color="#000000">COID_MethodDesc_constructor(</font>S,I,F)         <font color="#000000">MethodDesc(</font> S[<font color="#00D000">0</font>], S[<font color="#00D000">1</font>], &amp;S[<font color="#00D000">2</font>], <font color="#000000">COID_OUT_ARGS(</font>&amp;S[<font color="#00D000">2</font>]), I, F )
<font color="#000080">#define</font> COID_MethodDesc_constructor_NotImpl        <font color="#000000">MethodDesc(</font> NULL, NULL, NULL, NULL, <font color="#00D000">0</font>, <font color="#00D000">0</font> )



<font color="#0000FF">typedef</font> <font color="#0000FF">void</font> (example::*coid_fnc)();

<font color="#FF0000">/// fake function, should never be called:</font>
<font color="#0000FF">static</font> <font color="#0000FF">void</font> <font color="#000000">coid_throw(</font>) <font color="#000080">{</font><font color="#0000FF">throw</font> ersFE_EXCEPTION;<font color="#000080">}</font>

<font color="#FF0000">/// we need type cast in case there are 2 or more methods with the same name</font>
<font color="#000080">#define</font> <font color="#000000">COID_DISPATCH_CREATE_HOOK(</font>M,i,t,tc) \
	<font color="#0000FF">if</font>( i &lt; coid_fnc_count ) <font color="#000080">{</font> \
		<font color="#0000FF">if</font>( (coid_flags[i] &amp; COID_example_method_desc[i].flags &amp; MethodDesc::xACCESS_MODE) ) \
			coid_fnc_table[t] = (coid_fnc) (tc) &amp;example::M; \
		<font color="#0000FF">else</font> *(<font color="#0000FF">void</font> **) &amp;coid_fnc_table[t] = (<font color="#0000FF">void</font> *) coid_throw; \
	<font color="#000080">}</font>


<font color="#000080">#define</font> <font color="#000000">COID_DISPATCH_CREATE_CALLER_HOOK(</font>M,i,t) \
	<font color="#0000FF">if</font>( i &lt; coid_fnc_count ) <font color="#000080">{</font> \
		<font color="#0000FF">if</font>( (coid_flags[i] &amp; COID_example_method_desc[i].flags &amp; MethodDesc::xACCESS_MODE) ) \
			coid_fnc_table[t] = (coid_fnc) &amp;DISPATCH_CALLER_example_0_0::M; \
		<font color="#0000FF">else</font> *(<font color="#0000FF">void</font> **) &amp;coid_fnc_table[t] = (<font color="#0000FF">void</font> *) coid_throw; \
	<font color="#000080">}</font>






<font color="#FF0000">/// functions:</font>
<font color="#0000FF">uint</font> <font color="#000000">COID_example_0_0_get_method_id(</font> <font color="#0000FF">const</font> <font color="#0000FF">token</font> &amp; name );
<font color="#0000FF">opcd</font> <font color="#000000">COID_example_0_0_dispatch(</font> InstanceData * _coid_inst_data, <font color="#0000FF">uint</font> _coid_fnc_id, binstream &amp; _coid_bstr );



<font color="#0000FF">struct</font> DISPATCH_CALLER_example_0_0
<font color="#000080">{</font>
	<font color="#0000FF">void</font> <font color="#000000">call_dispatch(</font> binstream * b ) <font color="#000080">{</font>
		COID_CLIENT_EXESTREAM_ARGS * a = (COID_CLIENT_EXESTREAM_ARGS *) <font color="#0000FF">this</font>;
		InstanceData d;  d._object = a-&gt;obj;
		<font color="#000000">COID_example_0_0_dispatch(</font> &amp;d, a-&gt;id, *b );
	<font color="#000080">}</font>
<font color="#000080">}</font>;





<font color="#0000FF">enum</font> <font color="#000080">{</font>	<font color="#FF0000">/// command ids, format is: COID_classname_fncname_fncid</font>
	COID_example_read1_0 = <font color="#00D000">0</font>,
	COID_example_read2_1 = <font color="#00D000">1</font>,
	COID_example_send_2 = <font color="#00D000">2</font>,
	COID_example_remap_fnc_3 = <font color="#00D000">3</font>,
	COID_example_get_ptr_4 = <font color="#00D000">4</font>
<font color="#000080">}</font>;



<font color="#FF0000">/// info about every function:</font>
<font color="#0000FF">static</font> <font color="#0000FF">const</font> <font color="#0000FF">char</font> * COID_example_read1_0_finfo[] = <font color="#000080">{</font><font color="#000000">"read1"</font>, <font color="#000000">"opcd "</font>, NULL, <font color="#000000">"FOO_STRUCT &amp; list"</font>, NULL<font color="#000080">}</font>;
<font color="#0000FF">static</font> <font color="#0000FF">const</font> <font color="#0000FF">char</font> * COID_example_read2_1_finfo[] = <font color="#000080">{</font><font color="#000000">"read2"</font>, <font color="#000000">"opcd "</font>, NULL, <font color="#000000">"FOO_STRUCT &amp; list"</font>, NULL<font color="#000080">}</font>;
<font color="#0000FF">static</font> <font color="#0000FF">const</font> <font color="#0000FF">char</font> * COID_example_send_2_finfo[] = <font color="#000080">{</font><font color="#000000">"send"</font>, <font color="#000000">"opcd "</font>, <font color="#000000">"int &amp; ref"</font>, <font color="#000000">"const charstr &amp; command"</font>, NULL, <font color="#000000">"int &amp; ref"</font>, <font color="#000000">"binstreambuf &amp; reply"</font>, NULL<font color="#000080">}</font>;
<font color="#0000FF">static</font> <font color="#0000FF">const</font> <font color="#0000FF">char</font> * COID_example_remap_fnc_3_finfo[] = <font color="#000080">{</font><font color="#000000">"remap_fnc"</font>, <font color="#000000">"opcd "</font>, NULL, <font color="#000000">"REMAP_EXAMPLE &amp; arg"</font>, NULL<font color="#000080">}</font>;
<font color="#0000FF">static</font> <font color="#0000FF">const</font> <font color="#0000FF">char</font> * COID_example_get_ptr_4_finfo[] = <font color="#000080">{</font><font color="#000000">"get_ptr"</font>, <font color="#000000">"opcd "</font>, <font color="#000000">"FOO_STRUCT ** f"</font>, NULL, NULL<font color="#000080">}</font>;


<font color="#FF0000">/// create structure that holds everything about function:</font>
<font color="#0000FF">static</font> <font color="#0000FF">const</font> MethodDesc COID_example_method_desc[] = <font color="#000080">{</font>
	<font color="#000000">COID_MethodDesc_constructor(</font> COID_example_read1_0_finfo, <font color="#00D000">0</font>, MethodDesc::fACCESS_MODE_DIRECT | MethodDesc::fACCESS_MODE_INTERPROCESS | MethodDesc::fACCESS_MODE_REMOTE ),
	<font color="#000000">COID_MethodDesc_constructor(</font> COID_example_read2_1_finfo, <font color="#00D000">1</font>, MethodDesc::fACCESS_MODE_DIRECT | MethodDesc::fACCESS_MODE_INTERPROCESS | MethodDesc::fACCESS_MODE_REMOTE ),
	<font color="#000000">COID_MethodDesc_constructor(</font> COID_example_send_2_finfo, <font color="#00D000">2</font>, MethodDesc::fACCESS_MODE_DIRECT | MethodDesc::fACCESS_MODE_INTERPROCESS | MethodDesc::fACCESS_MODE_REMOTE | MethodDesc::fCONST ),
	<font color="#000000">COID_MethodDesc_constructor(</font> COID_example_remap_fnc_3_finfo, <font color="#00D000">3</font>, MethodDesc::fACCESS_MODE_DIRECT | MethodDesc::fACCESS_MODE_INTERPROCESS | MethodDesc::fACCESS_MODE_REMOTE | MethodDesc::fLOG_CALL ),
	<font color="#000000">COID_MethodDesc_constructor(</font> COID_example_get_ptr_4_finfo, <font color="#00D000">4</font>, MethodDesc::fACCESS_MODE_DIRECT | MethodDesc::fLOG_CALL )
<font color="#000080">}</font>;



<font color="#0000FF">static</font> <font color="#0000FF">const</font> <font color="#0000FF">char</font> * COID_dependencies_example[] = <font color="#000080">{</font>

	NULL
<font color="#000080">}</font>;


<font color="#FF0000">/// ServiceDescriptor:</font>
<font color="#0000FF">static</font> ServiceDescriptor COID_descriptor_example;



<font color="#FF0000">/// dispatch stores function tables for all 'direct' clients with different minor versions here</font>
<font color="#0000FF">class</font> COID_register_example_0_0
<font color="#000080">{</font>
	<font color="#0000FF">struct</font> table <font color="#000080">{</font>
		<font color="#0000FF">ulong</font> ver;
		coid_fnc * tbl;
	<font color="#000080">}</font>;
	<font color="#0000FF">dynarray</font><font color="#000000">&lt;table&gt;</font>	_tables;

<font color="#0000FF">public</font>:
<font color="#FF0000">//	comm_mutex_rw	_mx;</font>
	comm_mutex	_mx;

	<font color="#000000">COID_register_example_0_0(</font>) <font color="#000080">{</font>
		COID_descriptor_example._version.<font color="#000000">set(</font> <font color="#000000">""</font>, <font color="#00D000">0</font>, <font color="#00D000">0</font>, <font color="#00D000">1</font> );
		COID_descriptor_example._coid_version = COID_VERSION;
		COID_descriptor_example._name = <font color="#000000">"example"</font>;
		COID_descriptor_example._shortname = <font color="#000000">"example"</font>;
		COID_descriptor_example._info = <font color="#000000">"info :)"</font>;
		COID_descriptor_example._dependencies = COID_dependencies_example;
		COID_descriptor_example._nmeth = <font color="#00D000">5</font>;
		COID_descriptor_example._methflags = COID_example_method_desc;
		COID_descriptor_example._flags = ServiceDescriptor::fLOG_CALL | ServiceDescriptor::fALLOW_DIRECT_ACCESS | ServiceDescriptor::fALLOW_INTERPROCESS_ACCESS | ServiceDescriptor::fALLOW_REMOTE_ACCESS | ServiceDescriptor::fAUTONOMOUS;
		COID_descriptor_example._acceptor_port = (<font color="#0000FF">ulong</font>) -<font color="#00D000">1</font>;
		COID_descriptor_example._bin_svc_data = COID_bin_data;
		COID_descriptor_example.get_method_id = COID_example_0_0_get_method_id;
		COID_descriptor_example.dispatch = COID_example_0_0_dispatch;
		<font color="#000000">INTERFACE_REGISTER(</font>ServiceDescriptor).<font color="#000000">add(</font> &amp;COID_descriptor_example );
	<font color="#000080">}</font>

	~<font color="#000000">COID_register_example_0_0(</font>) <font color="#000080">{</font>
<font color="#FF0000">//		MXGUARDRW( (comm_mutex_rw &amp;) _mx );</font>
		<font color="#000000">MXGUARD(</font> (comm_mutex &amp;) _mx );
		<font color="#0000FF">for</font>( <font color="#0000FF">ulong</font> i=<font color="#00D000">0</font>; i&lt;_tables.<font color="#000000">size(</font>); i++ )
			<font color="#0000FF">delete</font> [] _tables[i].tbl;
	<font color="#000080">}</font>
	coid_fnc * <font color="#000000">get_table_notlocked(</font> <font color="#0000FF">ulong</font> ver ) <font color="#000080">{</font>
		<font color="#0000FF">for</font>( <font color="#0000FF">ulong</font> i=<font color="#00D000">0</font>; i&lt;_tables.<font color="#000000">size(</font>); i++ )
			<font color="#0000FF">if</font>( ver == _tables[i].ver ) <font color="#0000FF">return</font> _tables[i].tbl;
		<font color="#0000FF">return</font> NULL;
	<font color="#000080">}</font>
	coid_fnc * <font color="#000000">get_table(</font> <font color="#0000FF">ulong</font> ver ) <font color="#000080">{</font>
<font color="#FF0000">//		MXGUARDRW( (const comm_mutex_rw &amp;) _mx );		/// ==&gt; read lock</font>
		<font color="#000000">MXGUARD(</font> (<font color="#0000FF">const</font> comm_mutex &amp;) _mx );
		<font color="#0000FF">return</font> <font color="#000000">get_table_notlocked(</font> ver );
	<font color="#000080">}</font>
	<font color="#0000FF">void</font> <font color="#000000">insert_table(</font> <font color="#0000FF">ulong</font> ver, coid_fnc * tbl ) <font color="#000080">{</font>
		table * t = _tables.<font color="#000000">add(</font> <font color="#00D000">1</font> );	<font color="#FF0000">/// mutex has been locked</font>
		t-&gt;ver = ver; t-&gt;tbl = tbl;
	<font color="#000080">}</font>
<font color="#000080">}</font>;


<font color="#FF0000">// for dll linking</font>
COID_register_example_0_0 &amp; <font color="#000000">get_COID_register_example_0_0(</font>)
<font color="#000080">{</font>
	<font color="#0000FF">static</font> COID_register_example_0_0 x;
	<font color="#000000">coid_get_sdir(</font>);    <font color="#FF0000">//force exporting the symbol</font>
	<font color="#0000FF">return</font> x;
<font color="#000080">}</font>

<font color="#FF0000">//for static linking (must be called from outside to link this object)</font>
<font color="#0000FF">void</font> <font color="#000000">get_COID_register_example(</font>)
<font color="#000080">{</font>
	<font color="#000000">COID_register_example_0_0(</font>);
<font color="#000080">}</font>

<font color="#0000FF">static</font> COID_register_example_0_0 &amp; COID_auto_register_variable = <font color="#000000">get_COID_register_example_0_0(</font>);










<font color="#0000FF">opcd</font> <font color="#000000">COID_example_0_0_dispatch(</font> InstanceData * _coid_inst_data, <font color="#0000FF">uint</font> _coid_fnc_id, binstream &amp; _coid_bstr )
<font color="#000080">{</font>
	example * _coid_example_obj = (example *) _coid_inst_data-&gt;_object;
	<font color="#0000FF">double</font> _coid_example_ticks = <font color="#00D000">0.0</font>;
	binstream * _coid_log = NULL;
	<font color="#0000FF">opcd</font> _coid_err_code = <font color="#00D000">0</font>;

	<font color="#0000FF">switch</font>( _coid_fnc_id ) <font color="#000080">{</font>
		<font color="#0000FF">case</font> StdDispatchMethod::CONSTRUCTOR: <font color="#000080">{</font>
			_coid_inst_data-&gt;_object = _coid_example_obj = <font color="#0000FF">new</font> example;
			_coid_example_obj-&gt;<font color="#000000">accept_startup_params(</font> *_coid_inst_data-&gt;_cmdin );
			<font color="#0000FF">if</font>( _coid_err_code ) <font color="#000080">{</font>
				<font color="#0000FF">delete</font> (example *) _coid_inst_data-&gt;_object; _coid_inst_data-&gt;_object = NULL;
				<font color="#0000FF">return</font> _coid_err_code;
			<font color="#000080">}</font>
		<font color="#000080">}</font> <font color="#0000FF">break</font>;
		<font color="#0000FF">case</font> StdDispatchMethod::DESTRUCTOR: <font color="#000080">{</font>
			<font color="#0000FF">delete</font> _coid_example_obj; _coid_inst_data-&gt;_object = NULL;
		<font color="#000080">}</font> <font color="#0000FF">break</font>;
		<font color="#0000FF">case</font> StdDispatchMethod::CREATE_INTERFACE: <font color="#000080">{</font>
			Tptr<font color="#000000">&lt;CreateInterfaceInfo&gt;</font> coid_iface_info;
			_coid_bstr &gt;&gt; coid_iface_info;
			<font color="#0000FF">const</font> <font color="#0000FF">uint</font> coid_fnc_count = coid_iface_info-&gt;_nmethods;
			<font color="#0000FF">const</font> <font color="#0000FF">uint</font> * coid_flags = coid_iface_info-&gt;_methflags;
			coid_fnc * coid_fnc_table = <font color="#000000">get_COID_register_example_0_0(</font>).<font color="#000000">get_table(</font> coid_iface_info-&gt;_clientver.<font color="#000000">get_minor(</font>) );

			<font color="#0000FF">if</font>( ! coid_fnc_table ) <font color="#000080">{</font>
				<font color="#FF0000">//MXGUARDRW( get_COID_register_example_0_0()._mx );</font>
				<font color="#000000">MXGUARD(</font> <font color="#000000">get_COID_register_example_0_0(</font>)._mx );
				coid_fnc_table = <font color="#000000">get_COID_register_example_0_0(</font>).<font color="#000000">get_table_notlocked(</font> coid_iface_info-&gt;_clientver.<font color="#000000">get_minor(</font>) );
				<font color="#0000FF">if</font>( ! coid_fnc_table ) <font color="#000080">{</font>
					coid_fnc_table = (coid_fnc *) <font color="#0000FF">new</font> <font color="#0000FF">char</font>[ <font color="#0000FF">sizeof</font>(coid_fnc) * (coid_fnc_count + <font color="#00D000">1</font>) ];	<font color="#FF0000">/// new coid_fnc[...] would allocate pointer to 0 bytes (M$ 'feature')</font>
					<font color="#000000">memset(</font> coid_fnc_table, <font color="#00D000">0</font>, (coid_fnc_count + <font color="#00D000">1</font>) * <font color="#0000FF">sizeof</font>(coid_fnc) );
					<font color="#0000FF">ulong</font> coid_table_index = <font color="#00D000">0</font>;

					((CreateInterfaceInfo::t_fnc *) coid_fnc_table)[coid_table_index++] = coid_iface_info-&gt;_disconnect_interface;
					<font color="#000000">COID_DISPATCH_CREATE_HOOK(</font> read1, <font color="#00D000">0</font>, coid_table_index++, <font color="#0000FF">opcd</font> (example::*)( FOO_STRUCT &amp;  ) )
					<font color="#000000">COID_DISPATCH_CREATE_HOOK(</font> read2, <font color="#00D000">1</font>, coid_table_index++, <font color="#0000FF">opcd</font> (example::*)( FOO_STRUCT &amp;  ) )
					<font color="#000000">COID_DISPATCH_CREATE_HOOK(</font> send, <font color="#00D000">2</font>, coid_table_index++, <font color="#0000FF">opcd</font> (example::*)( <font color="#0000FF">int</font> &amp; , <font color="#0000FF">const</font> <font color="#0000FF">charstr</font> &amp; , binstreambuf &amp;  ) <font color="#0000FF">const</font> )
					<font color="#000000">COID_DISPATCH_CREATE_CALLER_HOOK(</font> call_dispatch, <font color="#00D000">3</font>, coid_table_index++ );  <font color="#FF0000">// remap_fnc contains fetch or remap args</font>
					<font color="#000000">COID_DISPATCH_CREATE_HOOK(</font> get_ptr, <font color="#00D000">4</font>, coid_table_index++, <font color="#0000FF">opcd</font> (example::*)( FOO_STRUCT **  ) )

					<font color="#000000">get_COID_register_example_0_0(</font>).<font color="#000000">insert_table(</font> coid_iface_info-&gt;_clientver.<font color="#000000">get_minor(</font>), coid_fnc_table );
				<font color="#000080">}</font>
			<font color="#000080">}</font>

			_coid_bstr.<font color="#000000">acknowledge(</font>);
			_coid_bstr &lt;&lt; (Tptr<font color="#000000">&lt;void&gt;</font> &amp;) coid_fnc_table;
			_coid_bstr &lt;&lt; (Tptr<font color="#000000">&lt;void&gt;</font> &amp;) _coid_inst_data-&gt;_object;
			_coid_bstr &lt;&lt; (Tptr<font color="#000000">&lt;void&gt;</font> &amp;) coid_iface_info-&gt;_mutex;
		<font color="#000080">}</font> <font color="#0000FF">break</font>;
		<font color="#0000FF">case</font> StdDispatchMethod::AUTHENTIFY: <font color="#000080">{</font>
			<font color="#0000FF">if</font>( (_coid_inst_data-&gt;_flags &amp; (MethodDesc::fLOG_CALL | MethodDesc::fLOG_DURATION)) == (MethodDesc::fLOG_CALL | MethodDesc::fLOG_DURATION) )
				_coid_example_ticks = <font color="#000000">SINGLETON(</font>HPTIMER).<font color="#000000">ftime(</font>);
			
			<font color="#0000FF">charstr</font> name;
			_coid_bstr &gt;&gt; name;
			password pwd;
			_coid_bstr &gt;&gt; pwd;

			<font color="#0000FF">if</font>( _coid_inst_data-&gt;_flags &amp; MethodDesc::fLOG_CALL ) <font color="#000080">{</font>
				_coid_log = &amp;_coid_inst_data-&gt;_cmdin-&gt;<font color="#000000">post_method(</font>);
				*_coid_log &lt;&lt; <font color="#000000">"("</font> &lt;&lt; <font color="#000000">"80000005"</font> &lt;&lt; <font color="#000000">") accept_connect ( "</font>; *_coid_log &lt;&lt; name; *_coid_log &lt;&lt; <font color="#000000">", "</font>; *_coid_log &lt;&lt; <font color="#000000">"?"</font>; *_coid_log &lt;&lt; <font color="#000000">" )"</font>;
			<font color="#000080">}</font>

			_coid_bstr.<font color="#000000">acknowledge(</font>);

			_coid_err_code = _coid_example_obj-&gt;<font color="#000000">accept_connect(</font> name, pwd );
			_coid_bstr &lt;&lt; _coid_err_code;
			

			<font color="#0000FF">if</font>( _coid_inst_data-&gt;_flags &amp; MethodDesc::fLOG_CALL ) <font color="#000080">{</font>
				*_coid_log &lt;&lt; <font color="#000000">"  --&gt;  ("</font>; *_coid_log &lt;&lt; <font color="#000000">")"</font>;
				<font color="#0000FF">if</font>( _coid_inst_data-&gt;_flags &amp; MethodDesc::fLOG_DURATION )
					*_coid_log &lt;&lt; <font color="#000000">" ["</font> &lt;&lt; (<font color="#000000">SINGLETON(</font>HPTIMER).<font color="#000000">ftime(</font>) - _coid_example_ticks) * <font color="#00D000">1000</font> &lt;&lt; <font color="#000000">"]"</font>;
				<font color="#0000FF">if</font>( ! _coid_err_code ) *_coid_log &lt;&lt; <font color="#000000">" .. ok"</font> &lt;&lt; EOM;
				<font color="#0000FF">else</font> *_coid_log &lt;&lt; <font color="#000000">" .. fail: "</font> &lt;&lt; <font color="#000000">opcd_formatter(</font>_coid_err_code) &lt;&lt; EOM;
			<font color="#000080">}</font>
			
		<font color="#000080">}</font> <font color="#0000FF">break</font>;
		<font color="#0000FF">case</font> StdDispatchMethod::AUTHENTIFY_SHARED: <font color="#000080">{</font>
			_coid_bstr.<font color="#000000">acknowledge(</font>);
			_coid_bstr &lt;&lt; _coid_err_code;
			<font color="#0000FF">return</font> ersNOT_IMPLEMENTED;
		<font color="#000080">}</font> <font color="#0000FF">break</font>;
		<font color="#0000FF">case</font> StdDispatchMethod::AUTHENTIFY_AUTO: <font color="#000080">{</font>
			_coid_bstr.<font color="#000000">acknowledge(</font>);
			_coid_bstr &lt;&lt; _coid_err_code;
			_coid_bstr.<font color="#000000">flush(</font>);
			<font color="#0000FF">return</font> ersNOT_IMPLEMENTED;
		<font color="#000080">}</font> <font color="#0000FF">break</font>;
		<font color="#0000FF">case</font> StdDispatchMethod::HANDLE_NET_LOOP: <font color="#000080">{</font>
			<font color="#0000FF">return</font> ersNOT_IMPLEMENTED;
		<font color="#000080">}</font> <font color="#0000FF">break</font>;
		<font color="#0000FF">case</font> StdDispatchMethod::PREDESTRUCTOR: <font color="#000080">{</font>
			_coid_bstr.<font color="#000000">acknowledge(</font>);
			_coid_bstr &lt;&lt; _coid_err_code;
			_coid_bstr.<font color="#000000">flush(</font>);
			<font color="#0000FF">return</font> ersNOT_IMPLEMENTED;
		<font color="#000080">}</font> <font color="#0000FF">break</font>;
		<font color="#0000FF">case</font> StdDispatchMethod::COMMAND: <font color="#000080">{</font>
			_coid_bstr.<font color="#000000">acknowledge(</font>);
			_coid_bstr &lt;&lt; _coid_err_code;
			_coid_bstr.<font color="#000000">flush(</font>);
			<font color="#0000FF">return</font> ersNOT_IMPLEMENTED;
		<font color="#000080">}</font> <font color="#0000FF">break</font>;
		<font color="#0000FF">case</font> StdDispatchMethod::SPAWN: <font color="#000080">{</font>
			_coid_bstr.<font color="#000000">acknowledge(</font>);
			_coid_bstr &lt;&lt; _coid_err_code;
			_coid_bstr.<font color="#000000">flush(</font>);
			<font color="#0000FF">return</font> ersNOT_IMPLEMENTED;
		<font color="#000080">}</font> <font color="#0000FF">break</font>;
		<font color="#0000FF">case</font> StdDispatchMethod::ECHO: <font color="#000080">{</font>
			_coid_bstr.<font color="#000000">acknowledge(</font>);
			_coid_bstr &lt;&lt; _coid_err_code;
			_coid_bstr.<font color="#000000">flush(</font>);
			<font color="#0000FF">return</font> ersNOT_IMPLEMENTED;
		<font color="#000080">}</font> <font color="#0000FF">break</font>;


		<font color="#FF0000">/// service-specific methods:</font>
		<font color="#0000FF">case</font> COID_example_read1_0: <font color="#000080">{</font>
			<font color="#0000FF">if</font>( (_coid_inst_data-&gt;_flags &amp; (MethodDesc::fLOG_CALL | MethodDesc::fLOG_DURATION)) == (MethodDesc::fLOG_CALL | MethodDesc::fLOG_DURATION) )
				_coid_example_ticks = <font color="#000000">SINGLETON(</font>HPTIMER).<font color="#000000">ftime(</font>);
			
			FOO_STRUCT list;

			<font color="#0000FF">if</font>( _coid_inst_data-&gt;_flags &amp; MethodDesc::fLOG_CALL ) <font color="#000080">{</font>
				_coid_log = &amp;_coid_inst_data-&gt;_cmdin-&gt;<font color="#000000">post_method(</font>);
				*_coid_log &lt;&lt; <font color="#000000">"("</font> &lt;&lt; COID_example_read1_0 &lt;&lt; <font color="#000000">") read1 ( "</font>; *_coid_log &lt;&lt; <font color="#000000">"?"</font>; *_coid_log &lt;&lt; <font color="#000000">" )"</font>;
			<font color="#000080">}</font>

			_coid_bstr.<font color="#000000">acknowledge(</font>);

			_coid_err_code = _coid_example_obj-&gt;<font color="#000000">read1(</font> list );
			_coid_bstr &lt;&lt; _coid_err_code;
			<font color="#0000FF">if</font>( ! _coid_err_code ) <font color="#000080">{</font>
				_coid_bstr &lt;&lt; list;
			<font color="#000080">}</font>

			_coid_bstr.<font color="#000000">flush(</font>);

			<font color="#0000FF">if</font>( _coid_inst_data-&gt;_flags &amp; MethodDesc::fLOG_CALL ) <font color="#000080">{</font>
				*_coid_log &lt;&lt; <font color="#000000">"  --&gt;  ("</font>; *_coid_log &lt;&lt; list; *_coid_log &lt;&lt; <font color="#000000">")"</font>;
				<font color="#0000FF">if</font>( _coid_inst_data-&gt;_flags &amp; MethodDesc::fLOG_DURATION )
					*_coid_log &lt;&lt; <font color="#000000">" ["</font> &lt;&lt; (<font color="#000000">SINGLETON(</font>HPTIMER).<font color="#000000">ftime(</font>) - _coid_example_ticks) * <font color="#00D000">1000</font> &lt;&lt; <font color="#000000">"]"</font>;
				<font color="#0000FF">if</font>( ! _coid_err_code ) *_coid_log &lt;&lt; <font color="#000000">" .. ok"</font> &lt;&lt; EOM;
				<font color="#0000FF">else</font> *_coid_log &lt;&lt; <font color="#000000">" .. fail: "</font> &lt;&lt; <font color="#000000">opcd_formatter(</font>_coid_err_code) &lt;&lt; EOM;
			<font color="#000080">}</font>
			
		<font color="#000080">}</font> <font color="#0000FF">break</font>;

		<font color="#0000FF">case</font> COID_example_read2_1: <font color="#000080">{</font>
			<font color="#0000FF">if</font>( (_coid_inst_data-&gt;_flags &amp; (MethodDesc::fLOG_CALL | MethodDesc::fLOG_DURATION)) == (MethodDesc::fLOG_CALL | MethodDesc::fLOG_DURATION) )
				_coid_example_ticks = <font color="#000000">SINGLETON(</font>HPTIMER).<font color="#000000">ftime(</font>);
			
			FOO_STRUCT * list;

			<font color="#0000FF">if</font>( _coid_inst_data-&gt;_flags &amp; MethodDesc::fLOG_CALL ) <font color="#000080">{</font>
				_coid_log = &amp;_coid_inst_data-&gt;_cmdin-&gt;<font color="#000000">post_method(</font>);
				*_coid_log &lt;&lt; <font color="#000000">"("</font> &lt;&lt; COID_example_read2_1 &lt;&lt; <font color="#000000">") read2 ( "</font>; *_coid_log &lt;&lt; <font color="#000000">"?"</font>; *_coid_log &lt;&lt; <font color="#000000">" )"</font>;
			<font color="#000080">}</font>

			_coid_bstr.<font color="#000000">acknowledge(</font>);

			_coid_err_code = _coid_example_obj-&gt;<font color="#000000">read2(</font> list );
			_coid_bstr &lt;&lt; _coid_err_code;
			<font color="#0000FF">if</font>( ! _coid_err_code ) <font color="#000080">{</font>
				_coid_bstr &lt;&lt; *list;
			<font color="#000080">}</font>

			_coid_bstr.<font color="#000000">flush(</font>);

			<font color="#0000FF">if</font>( _coid_inst_data-&gt;_flags &amp; MethodDesc::fLOG_CALL ) <font color="#000080">{</font>
				*_coid_log &lt;&lt; <font color="#000000">"  --&gt;  ("</font>; *_coid_log &lt;&lt; *list; *_coid_log &lt;&lt; <font color="#000000">")"</font>;
				<font color="#0000FF">if</font>( _coid_inst_data-&gt;_flags &amp; MethodDesc::fLOG_DURATION )
					*_coid_log &lt;&lt; <font color="#000000">" ["</font> &lt;&lt; (<font color="#000000">SINGLETON(</font>HPTIMER).<font color="#000000">ftime(</font>) - _coid_example_ticks) * <font color="#00D000">1000</font> &lt;&lt; <font color="#000000">"]"</font>;
				<font color="#0000FF">if</font>( ! _coid_err_code ) *_coid_log &lt;&lt; <font color="#000000">" .. ok"</font> &lt;&lt; EOM;
				<font color="#0000FF">else</font> *_coid_log &lt;&lt; <font color="#000000">" .. fail: "</font> &lt;&lt; <font color="#000000">opcd_formatter(</font>_coid_err_code) &lt;&lt; EOM;
			<font color="#000080">}</font>
			
		<font color="#000080">}</font> <font color="#0000FF">break</font>;

		<font color="#0000FF">case</font> COID_example_send_2: <font color="#000080">{</font>
			<font color="#0000FF">if</font>( (_coid_inst_data-&gt;_flags &amp; (MethodDesc::fLOG_CALL | MethodDesc::fLOG_DURATION)) == (MethodDesc::fLOG_CALL | MethodDesc::fLOG_DURATION) )
				_coid_example_ticks = <font color="#000000">SINGLETON(</font>HPTIMER).<font color="#000000">ftime(</font>);
			
			<font color="#0000FF">int</font> ref;
			_coid_bstr &gt;&gt; ref;
			<font color="#0000FF">charstr</font> command;
			_coid_bstr &gt;&gt; command;
			binstreambuf reply;

			<font color="#0000FF">if</font>( _coid_inst_data-&gt;_flags &amp; MethodDesc::fLOG_CALL ) <font color="#000080">{</font>
				_coid_log = &amp;_coid_inst_data-&gt;_cmdin-&gt;<font color="#000000">post_method(</font>);
				*_coid_log &lt;&lt; <font color="#000000">"("</font> &lt;&lt; COID_example_send_2 &lt;&lt; <font color="#000000">") send ( "</font>; *_coid_log &lt;&lt; ref; *_coid_log &lt;&lt; <font color="#000000">", "</font>; *_coid_log &lt;&lt; command; *_coid_log &lt;&lt; <font color="#000000">", "</font>; *_coid_log &lt;&lt; <font color="#000000">"?"</font>; *_coid_log &lt;&lt; <font color="#000000">" )"</font>;
			<font color="#000080">}</font>

			_coid_bstr.<font color="#000000">acknowledge(</font>);

			_coid_err_code = _coid_example_obj-&gt;<font color="#000000">send(</font> ref, command, reply );
			_coid_bstr &lt;&lt; _coid_err_code;
			<font color="#0000FF">if</font>( ! _coid_err_code ) <font color="#000080">{</font>
				_coid_bstr &lt;&lt; ref;
				_coid_bstr &lt;&lt; reply;
			<font color="#000080">}</font>

			_coid_bstr.<font color="#000000">flush(</font>);

			<font color="#0000FF">if</font>( _coid_inst_data-&gt;_flags &amp; MethodDesc::fLOG_CALL ) <font color="#000080">{</font>
				*_coid_log &lt;&lt; <font color="#000000">"  --&gt;  ("</font>; *_coid_log &lt;&lt; ref; *_coid_log &lt;&lt; <font color="#000000">", "</font>; *_coid_log &lt;&lt; reply; *_coid_log &lt;&lt; <font color="#000000">")"</font>;
				<font color="#0000FF">if</font>( _coid_inst_data-&gt;_flags &amp; MethodDesc::fLOG_DURATION )
					*_coid_log &lt;&lt; <font color="#000000">" ["</font> &lt;&lt; (<font color="#000000">SINGLETON(</font>HPTIMER).<font color="#000000">ftime(</font>) - _coid_example_ticks) * <font color="#00D000">1000</font> &lt;&lt; <font color="#000000">"]"</font>;
				<font color="#0000FF">if</font>( ! _coid_err_code ) *_coid_log &lt;&lt; <font color="#000000">" .. ok"</font> &lt;&lt; EOM;
				<font color="#0000FF">else</font> *_coid_log &lt;&lt; <font color="#000000">" .. fail: "</font> &lt;&lt; <font color="#000000">opcd_formatter(</font>_coid_err_code) &lt;&lt; EOM;
			<font color="#000080">}</font>
			
		<font color="#000080">}</font> <font color="#0000FF">break</font>;

		<font color="#0000FF">case</font> COID_example_remap_fnc_3: <font color="#000080">{</font>
			<font color="#0000FF">if</font>( (_coid_inst_data-&gt;_flags &amp; (MethodDesc::fLOG_CALL | MethodDesc::fLOG_DURATION)) == (MethodDesc::fLOG_CALL | MethodDesc::fLOG_DURATION) )
				_coid_example_ticks = <font color="#000000">SINGLETON(</font>HPTIMER).<font color="#000000">ftime(</font>);
			
			REMAP_EXAMPLE arg;

			<font color="#0000FF">if</font>( _coid_inst_data-&gt;_flags &amp; MethodDesc::fLOG_CALL ) <font color="#000080">{</font>
				_coid_log = &amp;_coid_inst_data-&gt;_cmdin-&gt;<font color="#000000">post_method(</font>);
				*_coid_log &lt;&lt; <font color="#000000">"("</font> &lt;&lt; COID_example_remap_fnc_3 &lt;&lt; <font color="#000000">") remap_fnc ( "</font>; *_coid_log &lt;&lt; <font color="#000000">"?"</font>; *_coid_log &lt;&lt; <font color="#000000">" )"</font>;
			<font color="#000080">}</font>

			_coid_bstr.<font color="#000000">acknowledge(</font>);

			_coid_err_code = _coid_example_obj-&gt;<font color="#000000">remap_fnc(</font> arg );
			_coid_bstr &lt;&lt; _coid_err_code;
			<font color="#0000FF">if</font>( ! _coid_err_code ) <font color="#000080">{</font>
				_coid_bstr &lt;&lt; arg;
			<font color="#000080">}</font>

			_coid_bstr.<font color="#000000">flush(</font>);

			<font color="#0000FF">if</font>( _coid_inst_data-&gt;_flags &amp; MethodDesc::fLOG_CALL ) <font color="#000080">{</font>
				*_coid_log &lt;&lt; <font color="#000000">"  --&gt;  ("</font>; *_coid_log &lt;&lt; arg; *_coid_log &lt;&lt; <font color="#000000">")"</font>;
				<font color="#0000FF">if</font>( _coid_inst_data-&gt;_flags &amp; MethodDesc::fLOG_DURATION )
					*_coid_log &lt;&lt; <font color="#000000">" ["</font> &lt;&lt; (<font color="#000000">SINGLETON(</font>HPTIMER).<font color="#000000">ftime(</font>) - _coid_example_ticks) * <font color="#00D000">1000</font> &lt;&lt; <font color="#000000">"]"</font>;
				<font color="#0000FF">if</font>( ! _coid_err_code ) *_coid_log &lt;&lt; <font color="#000000">" .. ok"</font> &lt;&lt; EOM;
				<font color="#0000FF">else</font> *_coid_log &lt;&lt; <font color="#000000">" .. fail: "</font> &lt;&lt; <font color="#000000">opcd_formatter(</font>_coid_err_code) &lt;&lt; EOM;
			<font color="#000080">}</font>
			
		<font color="#000080">}</font> <font color="#0000FF">break</font>;



		<font color="#0000FF">default</font>:
			_coid_bstr.<font color="#000000">acknowledge(</font> <font color="#0000FF">true</font> );
			_coid_bstr &lt;&lt; ersNOT_IMPLEMENTED;
			_coid_bstr.<font color="#000000">flush(</font>);
			<font color="#0000FF">return</font> ersNOT_IMPLEMENTED;
		<font color="#0000FF">break</font>;
	<font color="#000080">}</font>



	<font color="#0000FF">return</font> _coid_err_code;
<font color="#000080">}</font>












<font color="#FF0000">/// method table</font>
<font color="#0000FF">static</font> METHOD_TABLE COID_example_method_table[] = <font color="#000080">{</font>
	<font color="#000080">{</font><font color="#000000">"get_ptr"</font>, COID_example_get_ptr_4<font color="#000080">}</font>,
	<font color="#000080">{</font>NULL, UMAX<font color="#000080">}</font>,
	<font color="#000080">{</font>NULL, UMAX<font color="#000080">}</font>,
	<font color="#000080">{</font><font color="#000000">"remap_fnc"</font>, COID_example_remap_fnc_3<font color="#000080">}</font>,
	<font color="#000080">{</font><font color="#000000">"read2"</font>, COID_example_read2_1<font color="#000080">}</font>,
	<font color="#000080">{</font>NULL, UMAX<font color="#000080">}</font>,
	<font color="#000080">{</font><font color="#000000">"send"</font>, COID_example_send_2<font color="#000080">}</font>,
	<font color="#000080">{</font><font color="#000000">"read1"</font>, COID_example_read1_0<font color="#000080">}</font>
<font color="#000080">}</font>;



<font color="#000080">#define</font> <font color="#000000">COID_dispatch_method_size		(</font><font color="#0000FF">sizeof</font>(COID_example_method_table) / <font color="#0000FF">sizeof</font>(METHOD_TABLE))



<font color="#0000FF">uint</font> <font color="#000000">COID_example_0_0_get_method_id(</font> <font color="#0000FF">const</font> <font color="#0000FF">token</font> &amp; name )
<font color="#000080">{</font>
	hash<font color="#000000">&lt;token&gt;</font> mha;
	<font color="#0000FF">uint</font> idx = <font color="#000000">mha(</font>name) % COID_dispatch_method_size;

	<font color="#0000FF">for</font>( <font color="#0000FF">ulong</font> i=<font color="#00D000">0</font>; i&lt;COID_dispatch_method_size; i++ ) <font color="#000080">{</font>
		<font color="#0000FF">if</font>( COID_example_method_table[idx].name )
			<font color="#0000FF">if</font>( name == COID_example_method_table[idx].name )
				<font color="#0000FF">return</font> COID_example_method_table[idx].id;
		idx++;
		<font color="#0000FF">if</font>( idx == COID_dispatch_method_size ) idx = <font color="#00D000">0</font>;
	<font color="#000080">}</font>

	<font color="#0000FF">return</font> UMAX;
<font color="#000080">}</font>


<font color="#000080">}</font> <font color="#FF0000">// namespace coid</font>
</tt>
</pre>
